﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;

namespace MemoryDuosControl
{
    public class Ranking_Global
    {
        private string address;
        private List<PuntuacionRanking> rankingGlobal;

        public Ranking_Global()
        {
            address = Conexion.UrlPruebas + "rankingGlobal.php";
        }

        public List<PuntuacionRanking> recogerRanking()
        {
            String text;

            using (var webClient = new WebClient())
            {
                text = webClient.DownloadString(address);
            }
            return JsonConvert.DeserializeObject<List<PuntuacionRanking>>(text);
        }
    }
}

public class PuntuacionRanking
{
    [JsonProperty("Nick")]
    public string Nombre { get; set; }

    public int Puntuacion { get; set; }

    public override string ToString()
    {
        return "Nombre: " + Nombre + " Puntuacion: " + Puntuacion;
    }
}
